CREATE TABLE [dbo].[TCSERV_FACT]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TCSERV_FA__NU_AN__6477ECF3] DEFAULT (datepart(year,getdate())),
[CO_SERV_FACT] [dbo].[TD_VC_003] NOT NULL,
[CO_CNTA_EMPR] [dbo].[TD_VC_020_CNTA] NULL,
[CO_MONE] [dbo].[TD_VC_003] NOT NULL,
[NO_SERV_FACT] [dbo].[TD_VC_050] NULL,
[TI_OPER] [dbo].[TD_VC_003] NOT NULL,
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TCSERV_FA__FE_US__6754599E] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TCSERV_FA__FE_US__68487DD7] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TCSERV_FACT] ADD CONSTRAINT [CK__TCSERV_FA__CO_CN__66603565] CHECK (([CO_CNTA_EMPR]>='0' AND [CO_CNTA_EMPR]<='99999999999999999999'))
GO
ALTER TABLE [dbo].[TCSERV_FACT] ADD CONSTRAINT [CK__TCSERV_FA__NU_AN__656C112C] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TCSERV_FACT] ADD CONSTRAINT [XPKTCSERV_FACT] PRIMARY KEY CLUSTERED  ([CO_EMPR], [NU_ANNO], [CO_SERV_FACT]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TCSERV_FACT] ADD CONSTRAINT [FK1_TMPARA_CONT_A_TCSERV_FACT] FOREIGN KEY ([CO_EMPR]) REFERENCES [dbo].[TMPARA_CONT] ([CO_EMPR])
GO
ALTER TABLE [dbo].[TCSERV_FACT] ADD CONSTRAINT [FK1_TMPLAN_ANNO_A_TCSERV_FACT] FOREIGN KEY ([CO_EMPR], [CO_CNTA_EMPR]) REFERENCES [dbo].[TMPLAN_ANNO] ([CO_EMPR], [CO_CNTA_EMPR])
GO
